<template>
  <div class="app-container">
    <div class="filter-container">
      <el-form :inline="true" :model="formModel">
        <el-form-item class="no-warn-item" label="缺陷分类编码:" prop="classifyIssueCode">
          <el-input
            v-model="formModel.classifyIssueCode"
            class="filter-item "
            clearable
          />
        </el-form-item>
        <el-form-item class="no-warn-item" label="缺陷编码:" prop="issueCode">
          <el-input
            v-model="formModel.issueCode"
            class="filter-item "
            clearable
          />
        </el-form-item>
        <el-form-item class="no-warn-item" label="部位编码:" prop="carAreaCode">
          <el-input
            v-model="formModel.carAreaCode"
            class="filter-item "
            clearable
          />
        </el-form-item>
        <el-form-item class="no-warn-item" label="部件编码:" prop="carModulesCode">
          <el-input
            v-model="formModel.carModulesCode"
            class="filter-item "
            clearable
          />
        </el-form-item>
        <el-row class="submit-area">
          <el-col :span="24">
            <el-button
              v-if="hasPermission('modulesIssue_select')"
              type="primary"
              plain
              @click="queryList(false)"
            >查询
            </el-button>
            <el-button v-if="hasPermission('modulesIssue_add')" type="primary" plain @click="handleAdd">新增
            </el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <hey-table ref="table" :table-data="tableData" :columns="columns">
      <template slot="tools">
        <el-table-column
          label="操作"
          width="160"
          fixed="right"
          header-align="center"
          align="center"
        >
          <template slot-scope="{row}">
            <span
              v-if="hasPermission('modulesIssue_edit')"
              class="hey_tools_btn"
              @click="handleEdit(row)"
            >编辑</span>
            <span
              v-if="hasPermission('modulesIssue_del')"
              class="hey_tools_btn"
              @click="handleDelete(row)"
            >删除</span>
          </template>
        </el-table-column>
      </template>
    </hey-table>
    <el-dialog
      v-if="dialogVisible"
      v-dialogDrag
      :close-on-click-modal="false"
      title="车辆部件缺陷关系维护信息"
      :visible.sync="dialogVisible"
      width="60%"
    >
      <ModulesIssue-mnt :page-type="operateType" :edit-data="editData" @mntSuc="queryList" />
    </el-dialog>

  </div>
</template>

<script>

export default {
  name: 'ModulesIssueList',
  components: {
    ModulesIssueMnt: () => import('./modulesIssue-mnt')
  },
  props: {},
  data() {
    return {
      dialogVisible: false,
      operateType: '',
      editData: {},
      tableData: [],
      // 查询条件
      formModel: {
        classifyIssueCode: '',
        issueCode: '',
        carAreaCode: '',
        carModulesCode: ''
      },
      columns: [
        { title: '缺陷分类编码', key: 'classifyIssueCode' },
        { title: '缺陷分类描述', key: 'classifyIssueName' },
        { title: '缺陷编码', key: 'issueCode' },
        { title: '缺陷描述', key: 'issueName' },
        { title: '部位编码', key: 'carAreaCode' },
        { title: '部位描述', key: 'carAreaName' },
        { title: '部件编码', key: 'carModulesCode' },
        { title: '部件描述', key: 'carModulesName' },
        { title: '创建时间', key: 'createTime' },
        { title: '创建人', key: 'createUsername' },
        { title: '最后修改时间', key: 'lastUpdateTime' },
        { title: '最后修改人', key: 'lastUpdateUsername' }
      ]
    }
  },
  computed: {},
  methods: {
    queryList() {
      this.$refs.table.query('/modulesIssue/pageModulesIssue', this.formModel, '', false)
    },
    handleAdd() {
      this.operateType = 'add'
      this.dialogVisible = true
    },
    handleEdit(row) {
      this.dialogVisible = true
      this.operateType = 'edit'
      this.editData = row || {}
    },
    handleDelete(row) {
      this.$sure('确认删除？', _ => {
        this.post('/modulesIssue/deleteModulesIssue', {
          modulesIssueId: row.modulesIssueId
        }).then(_ => {
          this.$info('删除成功', this.queryList)
        })
      })
    }
  }
}
</script>
